/*!
 * \file frmem_stat.h
 *
 * \brief 内存统计
 *
 * All Rights Reserved Copyright (C) 2014 broada,Co.,Ltd.\n
 * 内存统计
 *
 * \version 2.0
 * \author yaohl
 * \date 2015/01/08
 *
 */
 
#ifndef __FRMEM_STAT_H_
#define __FRMEM_STAT_H_

#include "frmem_cfg.h"

#if FR_MEM_STAT

    typedef struct
    {
        unsigned int ui_idx;
        char arr_name[30];

        unsigned long ul_mem_used;
    } Frmemstat;

    #define FR_MEMSTAT_COUNT_MAX    500
    typedef struct
    {
        int i_count; //当前使用的个数
        int i_max;   //最大多少个
        Frmemstat *p_memstat[FR_MEMSTAT_COUNT_MAX];
    } Frmemstat_mng;

    typedef struct
    {
        void *p_st_memstat_mng;
        void *p_rwlock_lock;
    } Frmem_env;

    //int  __fr_memstat_init(size_t s_size, const char *p_slab_name);
    //void* __fr_memstat_init2(size_t s_size, const char *p_slab_name);
    void* __fr_memstat_init3(Frmem_env *p_memEnv, const char *p_slab_name);
    void __fr_memstat_set(void *p_st_memstat);

    void __fr_memstat_info(char **pp_outbuff);
    void __fr_memstat_info_all(char **pp_outbuff);
    void __fr_memstat_info_all_json(void *p_st_json);
    unsigned int __fr_memstat_all_used(void);
    void __fr_memstat_destroy(void);

    void *__fr_memstat_malloc(size_t s_size);
    char *__fr_memstat_strdup(const char *p_src);
    void *__fr_memstat_memdup(const void *p_src, size_t s_size);
    void __fr_memstat_free(void *p_free_data);
#endif

#endif

